// 链接：https://www.nowcoder.com/questionTerminal/5947ddcc17cb4f09909efa7342780048
// 来源：牛客网
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <unordered_map>
#include <string>
using namespace std;

class Solution {
public:
    int lengthOfLongestSubstring(string s)
    {
        int len = s.length();
        if(len==0) return 0;
        int maxLen = 0,left = 0;
        unordered_map<char,int> charMap;
        for(int i=0;i<len;i++)
        {
            if(charMap.find(s[i]) != charMap.end())
                left = max(left,charMap[s[i]]+1);
                //left = charMap[s[i]]+1;
            maxLen = max(maxLen,i-left+1);
            charMap[s[i]] = i;
        }
        return maxLen; 
    }
};

int main(){
    string s = "abba";
    return 0;
}